<template>
  <main>
    <c-navigation>
      <c-time @change="timeChangeHandler"/>
    </c-navigation>
    <c-card>
      <a-radio-group name="radioGroup" v-model="selectedValue">
        <a-radio :value="item.value"
                 :check="true"
                 v-for="item in selectData"
                 :key="item.value">
          {{ item.label }}
        </a-radio>
      </a-radio-group>
      <a-table class="custom"
               :columns="tableColumns"
               :data-source="tableData"
               :pagination="pagination"
               :rowKey="()=>Math.random()"/>

    </c-card>
  </main>
</template>

<script lang="ts">
import columns from "./assets/columns";
import {departmentAnalysisEvaluation} from "@/api/drgsGroupResults"

export default {
  data() {
    return {
      selectData: [
        {value: "a", label: "全部科室"},
        {value: "b", label: "优秀科室"},
        {value: "c", label: "良好科室"},
        {value: "d", label: "合格科室"}
      ],
      selectedValue: "a",
      tableColumns: columns,
      tableData: [],
      pagination: {
        pageSize: 10
      },
      timeParams: null
    }
  },
  mounted() {
    this.getDepartmentAnalysisEvaluation();
  },
  methods: {
    timeChangeHandler(e) {
      this.timeParams = e;
      this.getDepartmentAnalysisEvaluation()
    },
    async getDepartmentAnalysisEvaluation() {
      const params = {
        year: this.timeParams.year,
        month: this.timeParams.month
      }
      const res = await departmentAnalysisEvaluation(params);
      if (res['data']) {
        this.tableData = res['data'].map((item, index) => ({...item, ranking: index + 1}));
      }
    }
  }
}
</script>

<style scoped lang="stylus">
.custom {
  margin-top 20px
}
</style>
